<?php

class test extends Controller {
    
	function setVars()
	{
		$this->tpl['title'] = "Applications Test Page";
		$this->tpl['head'] = '';
        $this->tpl['sidebar'] = 'hello';
	}
    
	function __construct() 
	{
		parent::Controller();
        $this->auth->CheckTaMeR(101);
		$this->setVars();
        $this->load->model('Tamer_Model', 'mdb');
        $this->load->library('profiler');
        $this->tpl['profiler'] = TRUE;
        
	}
	function index()
	{
        $this->load->view('test/test', $this->tpl);
    }
    
    /**
    * @note	hcard 
    * @info	
    * @author	Dennis T. Kaplan
    * @access	public/private
    * @param	Vars array string mixed 
    * @return	
    */	
    public function hcard()
    {
        
        $hCard_data = array (
        'given_name' => 'Firstname',
        'middle_name' => 'Middlename',
        'family_name' => 'Lastname',
        'organization' => 'OrganizationName',
        'street' => '123 Street',
        'city' => 'City',
        'province' => 'Province/State',
        'postal_code' => 'Postal/Zip',
        'country' => 'Country',
        'phone' => 'phonenumber',
        'email' => 'email@yoursite.com',
        'url' => 'http://yoursite.com',
        'aim_screenname' => 'aimname',
        'yim_screenname' => 'yimname'
        );
        
        $this->load->helper('mf');
        $this->tpl['body'] = hcard($hCard_data);
        $this->load->view('blank', $this->tpl);
    }
    
    
	function test1()
	{
        $this->load->library('table');
        $dbmeta = $this->dbmeta();
        foreach($dbmeta as $f){
            $name = $f->name;
            $form[$f->name] = form_input(array(
            'name'        => $f->name,
            'id'          => $f->name,
            //'value'       => $$name,
            'maxlength'   => $f->max_length,
            'size'        => $f->max_length,
            'style'       => ''
            )
            );
        }
        echo form_open($f->table);
        echo $this->table->form_table($form);
        //echo form_hidden('id', $id);
        echo '</form>';
        echo $this->table->generate();
    }
    
    /* get column metadata */
 	function dbmeta()
    {
        $result = mysql_query('SELECT * FROM bb_event LIMIT 1');
        if (!$result) {
            die('Query failed: ' . mysql_error());
        }
        $i = 0;
        while ($i < mysql_num_fields($result)) {
            $meta = mysql_fetch_field($result, $i);
            if (!$meta) echo "No information available<br />\n";
            $r->$i = $meta;
            $i++;
        }
        return $r;
    }
    
}
?>